home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Extravaganza - Disc 4
/
Shareware Extravaganza - Over 25,000 Programs (The Ultimate Shareware Company)(Disc 4 of 4)(1993).iso
/
cad
/
arcldr2.zip
/
ARCLDR2.LSP
Wrap
Lisp/Scheme
|
1990-01-14
|
7KB
|
194 lines
;===========================================================
; ARCLDR.LSP
;(C) 1987 by Looking Glass Microproducts
;
; Arc Leader draws single- and multiple-arc leaders with
; curved arrowheads and dynamic text. If you have AutoCAD
; 2.6 or higher, Arcldr uses the DimSCALE DimASZ, and
; DimTXT variables to determine its arrow and text sizes.
; If you have an earlier version of AutoCAD, a size of
; 0.18*LTScale is used. Arcldr requires that the corrent
; text style does not have a fixed height associated with
; it.
; ----------------HOW TO USE ARCLDR.LSP--------------------
; Arcldr will prompt you for a start point at the text end
; of the leader, a direction from the start point and an
; endpoint for the arc segment. If you are using Release 9
; or higher, you will be dragging the endpoint of the arc.
; You will then be prompted for an offset distance. This
; is how far you wish to S-curve while creating a
; multiple-arc leader. A <RETURN> entered at this point
; completes the leader line, but if you enter (or point to)
; an offset distance, an S-curve will be drawn to this point
; from the end of the first arc. The S-curve consists of
; two arcs joined by a straight line segment. Then you will
; be prompted for a second arc and the process repeats.
; If you press <RETURN>, you finish drawing the arc segments
; Arcldr will draw a curved arrowhead and drop into the Dtext
; command, allowing you to provide multi-line leader text.
; The text is automatically placed appropiattely to left or
; right of the start point, opposite the first arc of the
; finished leader.
;-----------------------------------------------------------
; Input and debugged by William S. Brock from CADalyst
; magazine Vol. 5 No. 3 April 1988
;===========================================================
;--------------------------------------- ERROR HALT
(defun *error* (s)(princ (strcat "\n" s))
(setvar "blipmode" bm)
(princ))
;--------------------------------------- SAME POINT
(defun samepoint (p0 p1)(<= (distance p0 p1) 1.0E-6))
;----------------------------------------- DELTA XY
(defun dxy (p0 dx dy)
(list (+ (car p0) dx)(+ (cadr p0) dy)))
;--- QUADRANT OF STARTING ANGLE
(defun quadrant (a)
(fix (/ a (* 0.5 pi))))
;---------------------------------------------- TAN
(defun tan (a)
(/ (sin a) (cos a)))
;--- MAIN BODY
(defun c:arcldr ( / bm version twopi halfpi asiz tsiz
p0 p1 ename ent cen rad sa ea eam sp ep ccw len tp fp0
fp1 start lastp1 pastfp1 fr fd ho fe fc fc2 left om
langle langle0)
(graphscr)
;----------------------------- LINE ANGLES FOR BENDS
(setq
bangle (/ (* 65.0 PI) 180.0)
bm (getvar "blipmode")
om (getvar "orthomode")
;----------------------------------AUTOLSIP VERSION
version (atof (substr (ver) 18))
twopi (* 2.0 pi)
halfpi (* 0.5 pi)
lastp1 nil
;-------------------------------------- ARROW SIZE
asiz (if (>= version 2.6)
(* (getvar "dimscale")(getvar "dimasz"))
(* (getvar "ltscale") 0.18)
);..... End if
;--------------------------------------- TEXT SIZE
tsiz (if (>= version 2.6)
(* (getvar "dimscale")(getvar "dimtxt"))
(* (getvar "ltscale") 0.18)
);..... End if
);...........End setq
(setvar "cmdecho" 0)
(setvar "blipmode" bm)
;--------------------------- START POINT OF LEADER
(setq start (getpoint "\nFrom point: "))
;---------------------- CONTINUE IF POINT SELECTED
(if start
(progn
(setq p0 start)
(setvar "orthomode" 1);----------------- ORTHO ON
(while (null (setq langle (getangle p0 "\nDirection: "))
)
)
(setq langle
(if (<= halfpi langle (* 1.5 pi))
pi 0.0) langle0 langle)))
;---------------------------------------------MAIN LOOP
(while p0
(setvar "blipmode" bm)
(setvar "orthomode" 0)
(cond
( ( >= version 9.0)
(command "pline" p0 "width" 0 0 "arc"
"direction" (angtos langle) )
(prompt "\nTo point: ")
(command pause "";----------------------- GET END POINT
"explode" "l"))
(T (while (not (setq p1
(getpoint "\nTo point: " p0))))
(command "arc" p0 "e" p1 "d" (angtos langle))))
(setvar "blipmode" 0);--------------- SETS BLIPMODE OFF
;--------------------------------------- DISECT THE ARC
(setq
ename (entlast)
ent (entget ename)
cen (cdr (assoc 10 ent))
rad (cdr (assoc 40 ent))
sa (cdr (assoc 50 ent))
ea (cdr (assoc 51 ent))
eam (if (< ea sa)(+ ea twopi) ea)
sp (polar cen sa rad)
ep (polar cen ea rad)
ccw (samepoint sp p0)
len (* rad (abs (- eam sa)))
);..................................End setq
(if ccw
(setq tp (polar cen (- ea (/ asiz rad)) rad)
p1 ep a1 ea)
(setq tp (polar cen (+ sa (/ asiz rad)) rad)
p1 sp a1 sa)
);......END IF
;---------------------------------- ADD ANOTHER SEGMENT
(SETVAR "ORTHOMODE" 1)
(SETVAR "BLIPMODE" BM)
(setq p0 nil
ho (getdist p1"\nOffset distance: "))
(setvar "orthomode" 0)
(setvar "blipmode" 0)
(if ho
(progn
(setq quad (quadrant a1)
fr (/ ho (+ 1.0 (abs (sin a1))
(/ 2.0 (cos bangle))))
ls (* 2.0 fr (tan bangle))
fc (polar p1 a1 fr))
(cond ((= quad 0) (setq
fe (polar fc (- halfpi bangle) fr)
fc2 (polar fc halfpi (* fr (/ 2.0 (cos bangle))))))
((= quad 1) (setq
fe (polar fc (+ bangle halfpi) fr)
fc2 (polar fc halfpi (* fr (/ 2.0 (cos bangle))))))
((= quad 2) (setq
fe (polar fc (-(+ halfpi bangle)) fr)
fc2 (polar fc (- halfpi) (* fr (/ 2.0 (cos bangle))))))
((= quad 3) (Setq
fe (polar fc (- bangle halfpi) fr)
fc2 (polar fc (- halfpi) (* fr (/ 2.0 (cos bangle))))))
);...End cond
(while (null (setq langle (getangle (polar fc2 (angle fc fc2) fr)
"\nDirection: "))))
(setq p0 (polar fc2
(if ccw (- langle halfpi)
(+ langle halfpi)) fr))
(command "arc" "" fe "line" "" ls "" "arc" "" p0))))
;------------------------------------ DRAW THE ARROWHEAD
(IF (>= len (* 2 asiz))
(IF ccw
(command "pline" tp "w" (/ asiz 3.0) 0 "arc" "r" rad p1 "")
(command "pline" p1 "w" 0 (/ asiz 3.0) "arc" "r" rad tp "w" 0 0 "")))
;----------------------------------- ADD LEADER TEXT
(prompt "\nText: ")
(if (<= 1 (quadrant langle0) 2)
;--------------------------- LEADER TO LEFT OF START
(command "dtext" (dxy start tsiz (* -0.5 tsiz)) tsiz 0)
(command "dtext" "right" (dxy start (- tsiz)(* -0.5 tsiz)) tsiz 0))
(setvar "blipmode" bm)
(setvar "orthomode" om)
(princ)
)
;-----------------------------------MESSAGE WHEN LOADED
(princ "\nArcldr.LSP")
(princ "\n(C) 1987 by Looking Glass Microproducts")
(PRINC "\nTyped and debugged 5-1-88 by William S. Brock")
(PRIN1)
rror* (s)(princ (strcat "\n" s))
(setvar "blipmode" bm)
(princ))
;-------------------------------